home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Online / MiamiSDK / netinclude / net / if.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-12-08  |  5.8 KB  |  169 lines

  1. #ifndef _NET_IF_H_
  2. #define    _NET_IF_H_
  3.  
  4. #ifndef _SYS_TYPES_H_
  5. #include <sys/types.h>
  6. #endif
  7.  
  8. #ifndef _SYS_SOCKET_H_
  9. #include <sys/socket.h>
  10. #endif
  11.  
  12. #ifndef _SYS_TIME_H_
  13. #include <sys/time.h>
  14. #endif
  15.  
  16.  
  17. #define    IFF_UP        0x1        /* interface is up */
  18. #define    IFF_BROADCAST    0x2        /* broadcast address valid */
  19. #define    IFF_DEBUG    0x4        /* turn on debugging */
  20. #define    IFF_LOOPBACK    0x8        /* is a loopback net */
  21. #define    IFF_POINTOPOINT    0x10        /* interface is point-to-point link */
  22. #define    IFF_NOTRAILERS    0x20        /* avoid use of trailers */
  23. #define    IFF_RUNNING    0x40        /* resources allocated */
  24. #define    IFF_NOARP    0x80        /* no address resolution protocol */
  25. #define    IFF_PROMISC    0x100        /* receive all packets */
  26. #define    IFF_ALLMULTI    0x200        /* receive all multicast packets */
  27. #define    IFF_OACTIVE    0x400        /* transmission in progress */
  28. #define    IFF_SIMPLEX    0x800        /* can't hear own transmissions */
  29. #define    IFF_LINK0    0x1000        /* per link layer defined bit */
  30. #define    IFF_LINK1    0x2000        /* per link layer defined bit */
  31. #define    IFF_LINK2    0x4000        /* per link layer defined bit */
  32. #define    IFF_MULTICAST    0x8000        /* supports multicast */
  33.  
  34. /* flags set internally only: */
  35. #define    IFF_CANTCHANGE \
  36.     (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
  37.         IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
  38.  
  39.  
  40. struct    if_data {
  41. /* generic interface information */
  42.     u_char    ifi_type;    /* ethernet, tokenring, etc */
  43.     u_char    ifi_addrlen;    /* media address length */
  44.     u_char    ifi_hdrlen;    /* media header length */
  45.     u_long    ifi_mtu;    /* maximum transmission unit */
  46.     u_long    ifi_metric;    /* routing metric (external only) */
  47.     u_long    ifi_baudrate;    /* linespeed */
  48. /* volatile statistics */
  49.     u_long    ifi_ipackets;    /* packets received on interface */
  50.     u_long    ifi_ierrors;    /* input errors on interface */
  51.     u_long    ifi_opackets;    /* packets sent on interface */
  52.     u_long    ifi_oerrors;    /* output errors on interface */
  53.     u_long    ifi_collisions;    /* collisions on csma interfaces */
  54.     u_long    ifi_ibytes;    /* total number of octets received */
  55.     u_long    ifi_obytes;    /* total number of octets sent */
  56.     u_long    ifi_imcasts;    /* packets received via multicast */
  57.     u_long    ifi_omcasts;    /* packets sent via multicast */
  58.     u_long    ifi_iqdrops;    /* dropped on input, this interface */
  59.     u_long    ifi_noproto;    /* destined for unsupported protocol */
  60.     struct    timeval ifi_lastchange;/* last updated */
  61. };
  62.  
  63. /*
  64.  * The ifaddr structure contains information about one address
  65.  * of an interface.  They are maintained by the different address families,
  66.  * are allocated and attached when an address is set, and are linked
  67.  * together so all addresses for an interface can be located.
  68.  */
  69. struct ifaddr {
  70.     struct    sockaddr *ifa_addr;    /* address of interface */
  71.     struct    sockaddr *ifa_dstaddr;    /* other end of p-to-p link */
  72. #define    ifa_broadaddr    ifa_dstaddr    /* broadcast address interface */
  73.     struct    sockaddr *ifa_netmask;    /* used to determine subnet */
  74.     struct    ifnet *ifa_ifp;        /* back-pointer to interface */
  75.     struct    ifaddr *ifa_next;    /* next address for interface */
  76.     void (*ifa_rtrequest)(long,struct rtentry *,struct sockaddr *);
  77.     u_short    ifa_flags;        /* mostly rt_flags for cloning */
  78.     short    ifa_refcnt;        /* extra to malloc for link info */
  79.     long ifa_metric;        /* cost of going out this interface */
  80. };
  81. #define    IFA_ROUTE    RTF_UP        /* route installed */
  82.  
  83. /*
  84.  * Message format for use in obtaining information about interfaces
  85.  * from getkerninfo and the routing socket
  86.  */
  87. struct if_msghdr {
  88.     u_short    ifm_msglen;    /* to skip over non-understood messages */
  89.     u_char    ifm_version;    /* future binary compatability */
  90.     u_char    ifm_type;    /* message type */
  91.     long    ifm_addrs;    /* like rtm_addrs */
  92.     long    ifm_flags;    /* value of if_flags */
  93.     u_short    ifm_index;    /* index for associated ifp */
  94.     struct    if_data ifm_data;/* statistics and other data about if */
  95. };
  96.  
  97. /*
  98.  * Message format for use in obtaining information about interface addresses
  99.  * from getkerninfo and the routing socket
  100.  */
  101. struct ifa_msghdr {
  102.     u_short    ifam_msglen;    /* to skip over non-understood messages */
  103.     u_char    ifam_version;    /* future binary compatability */
  104.     u_char    ifam_type;    /* message type */
  105.     long    ifam_addrs;    /* like rtm_addrs */
  106.     long    ifam_flags;    /* value of ifa_flags */
  107.     u_short    ifam_index;    /* index for associated ifp */
  108.     long    ifam_metric;    /* value of ifa_metric */
  109. };
  110.  
  111. /*
  112.  * Interface request structure used for socket
  113.  * ioctl's.  All interface ioctl's must have parameter
  114.  * definitions which begin with ifr_name.  The
  115.  * remainder may be interface specific.
  116.  */
  117. struct    ifreq {
  118. #define    IFNAMSIZ    16
  119.     char    ifr_name[IFNAMSIZ];        /* if name, e.g. "en0" */
  120.     union {
  121.         struct    sockaddr ifru_addr;
  122.         struct    sockaddr ifru_dstaddr;
  123.         struct    sockaddr ifru_broadaddr;
  124.         short    ifru_flags;
  125.         long    ifru_metric;
  126.         long    ifru_mtu;
  127.         long    ifru_phys;
  128.         caddr_t    ifru_data;
  129.     } ifr_ifru;
  130. #define    ifr_addr    ifr_ifru.ifru_addr    /* address */
  131. #define    ifr_dstaddr    ifr_ifru.ifru_dstaddr    /* other end of p-to-p link */
  132. #define    ifr_broadaddr    ifr_ifru.ifru_broadaddr    /* broadcast address */
  133. #define    ifr_flags    ifr_ifru.ifru_flags    /* flags */
  134. #define    ifr_metric    ifr_ifru.ifru_metric    /* metric */
  135. #define    ifr_mtu        ifr_ifru.ifru_mtu    /* mtu */
  136. #define ifr_phys    ifr_ifru.ifru_phys    /* physical wire */
  137. #define    ifr_data    ifr_ifru.ifru_data    /* for use by interface */
  138. };
  139.  
  140. struct ifaliasreq {
  141.     char    ifra_name[IFNAMSIZ];        /* if name, e.g. "en0" */
  142.     struct    sockaddr ifra_addr;
  143.     struct    sockaddr ifra_broadaddr;
  144.     struct    sockaddr ifra_mask;
  145. };
  146.  
  147. /*
  148.  * Structure used in SIOCGIFCONF request.
  149.  * Used to retrieve interface configuration
  150.  * for machine (useful for programs which
  151.  * must know all networks accessible).
  152.  */
  153. struct    ifconf {
  154.     long    ifc_len;        /* size of associated buffer */
  155.     union {
  156.         caddr_t    ifcu_buf;
  157.         struct    ifreq *ifcu_req;
  158.     } ifc_ifcu;
  159. #define    ifc_buf    ifc_ifcu.ifcu_buf    /* buffer address */
  160. #define    ifc_req    ifc_ifcu.ifcu_req    /* array of structures returned */
  161. };
  162.  
  163. struct if_nameindex {
  164.     unsigned long    if_index;
  165.     char             *if_name;
  166. };
  167.  
  168. #endif /* !_NET_IF_H_ */
  169.